package com.yxy.utils;

import com.yxy.base.BusinessException;
import com.yxy.base.RestResponse;
import com.yxy.dao.TenantExtendMapper;
import com.yxy.feign.AuthService;
import com.yxy.feign.DTO.GetParamValueQueryDTO;
import com.yxy.feign.VO.AdminUserInToken;
import com.yxy.model.TenantExtend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Set;

/**
 * @author yuxiaoyang
 * @date 2020-10-20
 * app系统参数设置 帮助类
 */
@Service
public class SystemSettingHelper {
  @Value("${spring.application.name}")
  private String appName;//从配置文件中读取 项目的appName


  @Autowired
  private TokenCheckUtil tokenCheckUtil;

  @Autowired
  private AuthService authService;

  // 根据paramKey获取系统设置参数值
  public String getSystemSettingParam(String paramKey) {
    String invokeUnionAuthToken = tokenCheckUtil.getInvokeUnionAuthToken();

    GetParamValueQueryDTO inputDto = new GetParamValueQueryDTO();
    inputDto.setAppCode(appName);
    inputDto.setParamKey(paramKey);
    RestResponse<String> restResponse = authService.getParamValue(inputDto, invokeUnionAuthToken);
    return restResponse.getContent();
  }
}
